﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DbLayer;
using DataTier;

namespace BusinessTier
{

    public class PersonCtr
    {

        private static PersonCtr _instance = null;
        private IDbPerson _dbPerson = DbPerson.Instance;

        private PersonCtr()
        {

        }

        public static PersonCtr Instance
        {

            get
            {

                if (_instance == null)
                {
                    _instance = new PersonCtr();
                }

                return _instance;

            }

        }

        public void AddCustomer(string firstName, string lastName, string address, int zipCode, string email, string phone, string membership)
        {
            _dbPerson.AddCustomer(new Customer(firstName, lastName, address, zipCode, email, phone, membership));
        }

        public Customer GetCustomer(int customerId, string password)
        {

            Customer customer = _dbPerson.GetCustomer(customerId);

            if (customer != null)
            {
                if (customer.Phone != password)
                {
                    customer = null;
                }
            }

            return customer;

        }

        public IList<Customer> GetAllCustomers()
        {
            return _dbPerson.GetAllCustomers();
        }

        public void RemoveCustomer(int customerId)
        {
            throw new NotImplementedException();
        }

        public void AddEmployee(string firstName, string lastName, string address, int zipCode, string email, string phone)
        {
            _dbPerson.AddEmployee(new Employee(firstName, lastName, address, zipCode, email, phone));
        }

        public IList<Employee> GetAllEmployees()
        {
            return _dbPerson.GetAllEmployees();
        }

        public void RemoveEmploye(int empId)
        {
            throw new NotImplementedException();
        }

    }

}
